Function.prototype.mybind = function (content, ...args) {
  //先完成挂载，然后是改变this的指向，最后是柯里化返回
  if (content === "" || content === null || content === undefined)
    content = global;
  if (typeof content !== "object") content = new Object(content);
  const key = Symbol();
  content[key] = this;
  let arrs = []; //存放变量
  function curried(...arg) {
    arrs = [...arrs, ...arg];
    if (content[key].length <= arrs.length) {
      const res = content[key](...arrs);
      delete content[key];
      return res;
    } else {
      return curried;
    }
  }
  return curried(...args);
};

let obj = {
  a: 100,
  b: 200,
  c: 300,
};
function add(a, b, c) {
  console.log(this.a, this.b, this.c);
  console.log(a + b + c);
}
add(1, 2, 3);
console.log("---");
const r1 = add.mybind(obj, 1, 2);
r1(3);
